//
//  beginAnimationViewController.m
//  A段项目,漫画
//
//  Created by dllo on 15/4/25.
//  Copyright (c) 2015年 dllo. All rights reserved.
//

#import "beginAnimationViewController.h"
#define WIDTH self.view.frame.size.width
#define HEIGHT self.view.frame.size.height
@interface beginAnimationViewController ()
@property(nonatomic, retain)UICollectionView *beginCollection;
@property(nonatomic, retain)UIImageView *beginImageView;
@end

@implementation beginAnimationViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor yellowColor];
    [self createView];
//    [self createImage];
}

- (void)createView{
    UICollectionViewFlowLayout *flow = [[UICollectionViewFlowLayout alloc] init];
    flow.itemSize = CGSizeMake(WIDTH, HEIGHT);
    flow.minimumInteritemSpacing = 0;
    flow.minimumLineSpacing = 0;
    flow.scrollDirection = UICollectionViewScrollDirectionHorizontal;
    self.beginCollection = [[UICollectionView alloc] initWithFrame:CGRectMake(0, 0, WIDTH, HEIGHT) collectionViewLayout:flow];
    [self.view addSubview:self.beginCollection];
    [self.beginCollection release];
    self.beginCollection.delegate = self;
    self.beginCollection.dataSource = self;
    self.beginCollection.pagingEnabled = YES;
    [self.beginCollection registerClass:[BeginCollectionViewCell class] forCellWithReuseIdentifier:@"reuse"];
    
}

- (void)createImage{
    self.beginImageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, WIDTH, HEIGHT)];
    self.beginImageView.image = [UIImage imageNamed:@"7816d9c8a786c9179054b214ca3d70cf3ac757a1.gif"];
    [self.view addSubview:self.beginImageView];
    [self.beginImageView release];
}

- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{
    return 4;
}
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{
    BeginCollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"reuse" forIndexPath:indexPath];
    if (indexPath.row == 0) {
        cell.beginImage.image = [UIImage imageNamed:@"2.jpg"];
    }
    if (indexPath.row == 1) {
        cell.beginImage.image = [UIImage imageNamed:@"3.jpg"];
    }
    if (indexPath.row == 2) {
        cell.beginImage.image = [UIImage imageNamed:@"6.jpg"];
    }
    if (indexPath.row == 3) {
        cell.beginImage.image = [UIImage imageNamed:@"6e44b7bb8be22d9c52091a409779e88b.jpg"];
        cell.startButton.layer.borderWidth = 2;
        cell.startButton.layer.cornerRadius = 5;
        [cell.startButton setTitle:@"开始体验" forState:UIControlStateNormal];
        [cell.startButton addTarget:self action:@selector(startAction:) forControlEvents:UIControlEventTouchUpInside];
    }
    return cell;
}

- (void)startAction:(UIButton *)button{
    NSLog(@"开始体验");
    RootViewController *rootVC = [[RootViewController alloc] init];
    [self.navigationController pushViewController:rootVC animated:YES];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
